package com.micro.client;

import org.springframework.stereotype.Component;
import com.micro.request.MealOrderRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Component
public class TrainServiceClientFallback implements TrainServiceClient {
    
    @Override
    public Map<String, Object> getTrainByNumber(String trainNumber) {
        // 降级处理：返回默认列车信息
        Map<String, Object> train = new HashMap<>();
        train.put("列车ID", 0L);
        train.put("车次", trainNumber);
        train.put("始发站ID", 0L);
        train.put("终点站ID", 0L);
        train.put("始发时间", "00:00:00");
        train.put("终到时间", "00:00:00");
        return train;
    }
    
    @Override
    public Map<String, Object> getTrainById(Long trainId) {
        // 降级处理：返回默认列车信息
        Map<String, Object> train = new HashMap<>();
        train.put("列车ID", trainId);
        train.put("车次", "UNKNOWN");
        train.put("始发站ID", 0L);
        train.put("终点站ID", 0L);
        train.put("始发时间", "00:00:00");
        train.put("终到时间", "00:00:00");
        return train;
    }
    
    @Override
    public Long purchaseTicket(Long trainId, Integer seatType, Integer quantity, String travelDate) {
        // 降级处理：返回默认订单ID
        return 0L;
    }
    
    @Override
    public Map<String, Object> getSeatById(Long seatId) {
        // 降级处理：返回默认座位信息
        Map<String, Object> seat = new HashMap<>();
        seat.put("座位ID", seatId);
        seat.put("列车ID", 1L);
        seat.put("车厢ID", 1L);
        seat.put("座位号", "01A");
        seat.put("座位类型", 1);
        seat.put("价格", 100.00);
        return seat;
    }
    
    @Override
    public Map<String, Object> getStationById(Long stationId) {
        // 降级处理：返回默认站点信息
        Map<String, Object> station = new HashMap<>();
        station.put("站点ID", stationId);
        station.put("站点名称", "未知站点");
        station.put("城市", "未知城市");
        return station;
    }

    @Override
    public boolean processMealInventory(List<MealOrderRequest.MealOrderItemRequest> items) {
        // 降级处理：餐品库存处理失败
        return false;
    }
}
